fs: Avoid premature clearing of capabilities
authorJan Kara <jack@suse.cz>
Thu, 26 May 2016 15:21:32 +0000 (17:21 +0200)
committerBen Hutchings <ben@decadent.org.uk>
Wed, 4 Jan 2017 19:39:36 +0000 (19:39 +0000)
commite8995c90f3e4046c92b1a4224d143d09cf2d75a4
treec6079b1101bb4d7c05e6d8834617cf0be2bcf309
parent374411af8196945006fd70d350cef1e4f69fe60f
fs: Avoid premature clearing of capabilities

Currently, notify_change() clears capabilities or IMA attributes by
calling security_inode_killpriv() before calling into ->setattr. Thus it
happens before any other permission checks in inode_change_ok() and user
is thus allowed to trigger clearing of capabilities or IMA attributes
for any file he can look up e.g. by calling chown for that file. This is
unexpected and can lead to user DoSing a system.

Fix the problem by calling security_inode_killpriv() at the end of
inode_change_ok() instead of from notify_change(). At that moment we are
sure user has permissions to do the requested change.

References: CVE-2015-1350
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Jan Kara <jack@suse.cz>
Gbp-Pq: Topic bugfix/all
Gbp-Pq: Name fs-Avoid-premature-clearing-of-capabilities.patch
fs/attr.c